# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Carlos Aznarán <caznaranl@uni.pe>

pkgbase=qxlsx
pkgname=($pkgbase-qt5 $pkgbase-qt6)
pkgver=1.4.6
pkgrel=1
pkgdesc='Excel file reader/writer library using Qt'
arch=(loong64 x86_64)
url='https://github.com/QtExcel/QXlsx'
license=(MIT)
makedepends=(cmake qt5-base qt6-base)
source=(https://github.com/QtExcel/QXlsx/archive/v$pkgver/$pkgbase-$pkgver.tar.gz)
sha256sums=('969a947af6a78dad9f2418dfc84e528d212ceb98e6392edf859dbff4f8828a77')

build() {
  cmake -B build5 -S QXlsx-$pkgver/QXlsx \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DQT_VERSION_MAJOR=5 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build5

  cmake -B build6 -S QXlsx-$pkgver/QXlsx \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DQT_VERSION_MAJOR=6 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build6
}

package_qxlsx-qt5() {
  depends=(qt5-base)

  DESTDIR="$pkgdir" cmake --install build5
  install -Dm644 QXlsx-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}

package_qxlsx-qt6() {
  depends=(qt6-base)

  DESTDIR="$pkgdir" cmake --install build6
  install -Dm644 QXlsx-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname 
}
